const app = getApp(),url = app.globalData.url;
Page({
  data: {
    listdata:[
    ],
    where:{
      user_uid:'',
      pageNum:0,
      pageSize:8,
    },
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onShow: function (options) {
    var that = this
    var user_massage = wx.getStorageSync('user_massage')
    that.data.where.user_uid = user_massage.userUid
    that.data.where.pageNum ++
    var where = that.data.where
    var listdata = that.data.listdata
    wx.request({
      header: {
        'content-type': 'application/json' // 默认值
      },
      url:url+'myCollection/getMyCollectionList',
      method: "GET",
      data:where,
      success:function(res){
        console.log("收藏列表",res);
        var ret = res.data
        if(ret.code == 200){
          if(ret.data.content != ''){
            var listdata=ret.data.content
            // listdata=listdata.concat(ret.data.content)
            that.setData({listdata})
          }else{
            wx.showToast({
              title: '没有数据了~',
              icon:'none'
            })
          }
        }else{
          wx.showToast({
            title: ret.msg,
            icon:'none'
          })
        }
      }
    })
  },

  detail(e){
    console.log(e)
    var user_massage = wx.getStorageSync('user_massage')
    var positionid = e.currentTarget.dataset.positionid// 职位企业的ID 
    var id = e.currentTarget.dataset.id//收藏的ID
    wx.navigateTo({
      url: '/HomePage/workdetail/workdetail?id='+positionid +'&collid='+id,
    })
  },
  onReachBottom: function () {
    var that = this
      that.Bottom()    
  },
  Bottom: function () {
    var that = this
    var user_massage = wx.getStorageSync('user_massage')
    that.data.where.user_uid = user_massage.userUid
    that.data.where.pageNum ++
    var where = that.data.where
    var listdata = that.data.listdata
    wx.request({
      header: {
        'content-type': 'application/json' // 默认值
      },
      url:url+'myCollection/getMyCollectionList',
      method: "GET",
      data:where,
      success:function(res){
        console.log("收藏列表",res);
        var ret = res.data
        if(ret.code == 200){
          if(ret.data.content != ''){
            listdata=listdata.concat(ret.data.content)
            that.setData({listdata})
          }else{
            wx.showToast({
              title: '没有数据了~',
              icon:'none'
            })
          }
        }else{
          wx.showToast({
            title: ret.msg,
            icon:'none'
          })
        }
      }
    })
  },



  onHide: function () {
    var that = this
    that.data.where.pageNum = 0
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    var that = this
    that.data.where.pageNum = 0
  },
})